package com.zhiwei.msf.common.config;

import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

/**
 * 消息国际化配置配置
 */
@Component
@Slf4j
public class MessageSourceConfig {

	@Bean
	public MessageSource messageSource() {
		ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
		messageSource.setUseCodeAsDefaultMessage(true);
		messageSource.setDefaultEncoding("UTF-8");
		messageSource.setCacheSeconds(0);
		messageSource.addBasenames("classpath:message/exception");
		messageSource.addBasenames("classpath:message/common-exception");
		log.info("完成消息国际化配置：{}", messageSource.getBasenameSet());
		return messageSource;
	}
}